<!--首先加载主题subject详细信息-->
<!--留言message信息-->
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>详情界面</title>
	<link rel="stylesheet" type="text/css" href="css/lianjie.css">
	<style type="text/css">
		#question{
			width: 60%;
			background-color: #faebd7;
		}
		#name{
			color: green;
			font-weight: bold;
			margin: 10px;
		}
		#content{
			color: black;
		}
		#answers{
			width: 60%;
			background-color: #f0f8ff;
			padding: 10px;
			height: 70px;
			border-bottom: 1px dashed #000000;
		}
		#aleft{
			float: left;
			height: 50px;
			width: 15%;
		}
		#aright{
			float: left;
			height: 50px;
			width: 85%;
		}
		.gonggaolianjie{
			position: absolute;
			top: 80px;
			left: 1200px;
		}
		form{
			min-height: 500px;
			margin-left:15px;
			margin-top: 15px;
			width: 70%;
		}
		a{
		text-decoration: none;
	}
	a:hover{
		text-decoration: underline;
	}
	</style>
</head>
<body>
<!-- 加载头部信息 -->
<?php
include_once("header.php");
?>
<!--主题问题描述-->
<div id="question">
	<?php
	//获取subjectid
	if(isset($_GET["action"])&&$_GET["action"]=="show"&&isset($_GET["subjectid"])){
		$subjectid=$_GET["subjectid"];
	}else{
		$subjectid=0;//指定一个友好的错误新消息界面
	}
	//首先查询指定的主题信息
	$selectsubject="select * from subject where subjectid='$subjectid'";
	include_once("database.php");
	$result=mysql_query($selectsubject) or die("查询{$subjectid}主体信息失败:".mysql_error()."<br/>");
	if(mysql_num_rows($result)>0){
		$row=mysql_fetch_array($result);
		$title=$row["title"];
		$description=$row["description"];
		$questioner=$row["questioner"];
		$dates=$row["dates"];
		//下面把他们显示出来
		//注意定界符的书写方法
		echo <<<xqquestion
		<h1>{$title}</h1>
		<span id="name">{$questioner}</span><span>{$dates}</span>
		<p id="content">{$description}</p>
xqquestion;
	}
	?>
</div>
<!--主题回复描述 加载回复信息-->
<?php
$selectanswers="select answerr,dates,description from answers where subjectid='$subjectid' order by dates desc";
@include_once("database.php");
$result=mysql_query($selectanswers) or die("{$subjectid}主题信息的回复加载失败:".mysql_error()."<br/>");
while($row=mysql_fetch_array($result,MYSQL_ASSOC)){
	$answer=$row["answerr"];
	$dates=$row["dates"];
	$description=$row["description"];
	//显示样式
	echo <<<showanswer
	<div id="answers">
	<div id="aleft">{$answer}<br/><br/>{$dates}</div>
	<div id="aright"><p id="content">{$description}<p></div>
	</div>
showanswer;
}
?>
<!--机房公告和友情链接-->
<div class="gonggaolianjie">
	<div class="right-text right-text1">
		<h1>机房公告</h1>
		<div class="right-text1-a">
			<a href="">机房留言本系统V1.0发布</a>
			<a href="">网站网址更改公告</a>
			<a href="">机房电脑使用说明指南</a>
			<a href="">关于张三同学违反机房使用的处罚决定</a>
			<a href="">2018年软考安排公告</a>
			<a href="">机房监控使用公告</a>
			<a href="">大学英语四级考试说明</a>
			<a href="">机房使用说明</a>
		</div>
	</div>
	<div class="right-text right-text2">
		<h1>友情链接</h1>
		<div class="right-text2-a">
			<a href="http://xshxy.gxun.edu.cn/">广西民族大学相思湖学院</a>
			<a href="http://www.gxun.edu.cn//">广西民族大学</a>
			<a href="http://www.gxu.edu.cn//">广西大学</a>
			<a href="http://www.gxnu.edu.cn/">广西师范民族大学</a>
		</div>
	</div>
</div>
<!--回复输入框-->
<form action="" method="post">
我要回复:<br/>
<textarea name="ans" rows="10" cols="70">
输入内容
</textarea><br/><br/>
<input type="submit" name="submit" value="提交回复" style="color: white;font-size: 20px;background: #006f65;width: 150px;height: 40px;"><br/>
</form>
<?php
if(isset($_POST["submit"])&&$_POST["submit"]=="提交回复"){
	$description=$_POST["ans"];
	date_default_timezone_set("Asia/Shanghai");
	$dates=date("Y-m-d H:m:s");
	$answer=$username;//从cookie里获取当前登录用户的名字
	$insertintoanswer="insert into answers(subjectid,description,dates,answerr) values('$subjectid','$description','$dates','$answer')";
	@include_once("database.php");
	@mysql_query($insertintoanswer) or die("{$answer} 回复{$subjectid}失败了:".mysql_error()."<br/>");
	//插入就是成功
	//修改主题里的回复数
	$updatesubjectanswers="update subject set answers=answers+1 where subjectid='$subjectid'";
	@mysql_query($updatesubjectanswers) or die("修改{$subjectid}的回复数失败:".mysql_error()."<br/>");
	header("Location:xiangqing.php?action=show&subjectid={$subjectid}");
}
?>



<!-- 加载底部信息 -->
<?php
include_once("footer.php");
?>
</body>
</html>